#include <iostream>
#include <cstring>
#include <algorithm>
#define int long long

using namespace std;
const int N = 1e5 + 10;
int T;
int n,m,l,v;

struct car{
    int d,v,a;
}c[N];

int p[N];
int cnt,ans = 0x3f3f3f3f;

int get_speed(int a,int x,int v0)
{
    return v0 * v0 + 2 * a * x;
}

bool check(car x,int h[],int k)
{
    for (int i = 1;i <= k;i ++)
    {
        if (x.d > h[i]) continue;
        if (get_speed(x.a,h[i] - x.d,x.v) > v) return true;
    }
    return false;
}

void dfs(int idx,int v[],int Size)
{
    if (idx == m + 1)
    {
        /*for (int i = 1;i <= Size;i ++) cout << v[i] << " " ;
        cout << Size << endl;*/
        int u = 0;
        for (int i = 1;i <= n;i ++)
            if(check(c[i],v,Size) == true) u ++;
        if (u == cnt) ans = min(ans,Size);
        return;
    }
    v[Size + 1] = p[idx];
    dfs(idx + 1,v,Size + 1);
    v[Size + 1] = 0;
    dfs(idx + 1,v,Size);
}

signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;
    while (T --)
    {
        ans = 0x3f3f3f3f;
        cin >> n >> m >> l >> v;
        v = v * v;
        for (int i = 1;i <= n;i ++)
        {
            cin >> c[i].d >> c[i].v >> c[i].a;
        }
        for (int i = 1;i <= m;i ++) cin >> p[i];
        cnt = 0;
        for (int i = 1;i <= n;i ++)
            if (check(c[i],p,m) == true) cnt ++;
        cout << cnt << " ";
        int v[N];
        dfs(1,v,0);
        cout << m - ans << endl;
    }
    return 0;
}
